#coding:utf-8
'''
Created on 2015年4月20日

@author: leoZ
'''

from com.cyou.com.DBUtils import DBUtils
#FTPJobSource
class EtlFtpSourceEntity(object):
    def __init__(self,etlSystemName,etlJobName,ftpFilePath,ftpIp,ftpPort,ftpUser,ftpPassword,myId):    
        self.etlSystemName = etlSystemName
        self.etlJobName = etlJobName
        self.ftpFilePath = ftpFilePath
        self.ftpIp = ftpIp
        self.ftpPort = ftpPort
        self.ftpUser = ftpUser
        self.ftpPassword = ftpPassword
        self.myId = myId
#Dao
class EtlFtpSourceDao(object):
    def loadAll(self):
        connection = DBUtils().getConnection()
        cursor = connection.cursor()
        cursor.execute("select * from etl_ftp_source")
        cursor.rowfactory = EtlFtpSourceEntity
        return cursor.fetchall()
    #通过jobSourceEntity，返回符合条件的jobSource
    def loadAllFtpJobSourceByJobSource(self, jobSourceEntity):
        return self.loadAllJobSourceByJobName(jobSourceEntity.etlSystemName, jobSourceEntity.etlJobName)
    #通过系统名和任务明，返回符合条件的jobSource
    def loadAllJobSourceByJobName(self,etlSystemName,etlJobName):
        connection = DBUtils().getConnection()
        cursor = connection.cursor()
        sql = "select * from etl_ftp_source where ETLSYSTEMNAME = '%s' and ETLJOBNAME = '%s'" % (etlSystemName,etlJobName)
        cursor.execute(sql)
        cursor.rowfactory = EtlFtpSourceEntity
        return cursor.fetchall()